
<?php
    include('../config.ini.php');
    include('function.php');
    
    $db = db_connect();
    
    $product_set_id = $_POST['product_set_id'];
    
    $sql = "SELECT * FROM products WHERE product_set_id=$product_set_id AND product_show=1 ORDER BY product_position";
    $result = mysql_query($sql);
    $i = 1;
    $product_lits = '';
    while($row=mysql_fetch_assoc($result)){
	if(file_exists('../images/products/'.$row['product_id'].'/c_'.$row['product_img']) && trim($row['product_img'])!=''){
	    $img__ = 'images/products/'.$row['product_id'].'/c_'.$row['product_img'];
	}else{
	    $img__ = 'images/products/no-pic.jpg';
	}
	
	if($i==1){
	    $product_lits .=<<<showcase_lits
		<li id="{$row['product_id']}">
		    <img src="images/products/{$row['product_id']}/{$row['product_img']}" alt="{$row['product_title']}" class="product_thumb_gallery thumb_active" />
		</li>
showcase_lits;
            $product_img_first = $img__;
            $product_first_id = $row['product_id'];
            $product_first_title = $row['product_title'];
            $product_first_w = $row['product_width'];
            $product_first_d = $row['product_depth'];
            $product_first_h = $row['product_height'];
            $product_first_material = $row['product_material'];
	}else{
	    $product_lits .=<<<showcase_lits
		<li id="{$row['product_id']}">
		    <img src="images/products/{$row['product_id']}/{$row['product_img']}" alt="{$row['product_title']}" class="product_thumb_gallery" />
		</li>
showcase_lits;
	}
	
	$i++;
    }
    //$product_lits .= $product_lits;
    //$product_lits .= $product_lits;
    //$product_lits .= $product_lits;
    
    $house_['product_thumb_list'] = '<ul>'.$product_lits.'</ul>';
    $house_['product_img'] = $product_img_first;
    $house_['product_detail'] =<<<showcase_img_lits
            <span>Product</span> : {$product_first_title}<br />
	    <span>Dimension</span> : {$product_first_w} x {$product_first_d} x {$product_first_h}<br />
	    <span>Material</span> : {$product_first_material}<br />
showcase_img_lits;
    $house_['product_order_link'] = '<a href="order.php?product_id='.$product_first_id.'" title="Order '.$product_first_title.'" class="order"><img src="images/product_order_bt.jpg" alt="Order '.$product_first_title.'" id="product_order_bt" /></a>';
    
    echo json_encode($house_);
    
    db_close($db);
?>